/**
 * 
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 *   
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 * 
 */
package org.jiopi.ibean.share;

import java.util.logging.Logger;
import java.util.regex.Pattern;

import org.jiopi.framework.core.Config;
import org.jiopi.ibean.loader.log.LoaderLogUtil;
import org.jiopi.ibean.share.ShareUtil.StringUtil;
/**
 * 
 * 共享常量
 * 
 * @since 2010.4.9
 *
 */
public class ShareConstants {
	//installer use
	public final static String IBEAN_HOME = "ibean.home";
	
	
	public final static String FILE_PROTOCOL = "file";	
	public final static String IBEAN_WORK_DIR = "ibean.work.dir";
	public final static String IBEAN_WORK_DIR_DEFAULT = "${java.io.tmpdir}/ibean/";
	public final static String IBEAN_DOWNLOAD_DIR = "ibean.download.dir";
	public final static String IBEAN_CONNECT_TIMEOUT = "ibean.connect.timeout";
	public final static String IBEAN_DEBUG_MODE = "ibean.debug.mode";
	public final static boolean IBEAN_DEBUG_MODE_DEFAULT = false;
	public final static String IBEAN_CONNECT_TIMEOUT_DEFAULT = "5000";
	public final static String IBEAN_AUTOUPDATE_INTERVAL="ibean.autoupdate.interval";
	public final static String IBEAN_AUTOUPDATE_INTERVAL_DEFAULT="0";
	
	public final static String PROGRAM_PATH = "/program/";
	
	public final static String LOGS_DIR_PATH= "/logs/";
	
	public final static String IBEAN_PROGRAM_PATH = "/ibean/";
	public final static String BOOTSTRAP_DIR_PATH = "/bootstrap/";
	
	public final static Pattern VERSION_PATTERN = Pattern.compile("^\\d+(\\.\\d+){0,4}$");
	
	public final static int connectTimeout;
	public final static boolean debugMode;
	
	public static Logger shareLogger = LoaderLogUtil.getLoaderLogger();
	
	static{
		connectTimeout = StringUtil.getInt(Config.getConfig(IBEAN_CONNECT_TIMEOUT) , IBEAN_CONNECT_TIMEOUT_DEFAULT);
		debugMode = StringUtil.getBoolean(Config.getConfig(IBEAN_DEBUG_MODE), IBEAN_DEBUG_MODE_DEFAULT);
	}
}
